package com.zhx.basis.juc;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;

public class 集合线程安全问题 {
    public static void main(String[] args) {
        //List<String> strings1=new ArrayList<>();
//        List<String> strings1=new Vector<>();
//        List<String> strings1=Collections.synchronizedList(new ArrayList<>());
        List<String> strings1=new CopyOnWriteArrayList<>();
        for (int i = 0; i <30 ; i++) {
            new Thread(()->{
                strings1.add(UUID.randomUUID().toString().substring(0,8));
                System.out.println(strings1);
            },"线程"+i).start();
        }
    }
}
